<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
            + request.getServerPort() + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="<%=basePath%>">
    <script src="resources/js/base.js"></script>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	      <title>在线课件</title>
</head>
<body>
		<%@ include file="../common/navbar.jsp"%>	
<div class="container">
	<div class="row">
		<div class="col-md-12">
			<br>
			<!-- 查询窗口 -->
			<form class="form-inline"  action="courselist">
				<div class="form-group">
					<strong>话题名称:</strong>
					<input type="text" class="form-control" name="name" value="${name }">
				</div>
				<button type="submit" class="btn btn-primary btn-sm">查询</button>
			</form>
			<hr/>
			<div class="btn-group btn-group-sm f-size12">
				<a href="bbsaddview" class="btn btn-info">
			     <span class="glyphicon glyphicon-plus-sign"></span> 添加</a>
				 <a class="btn btn-warning" href="javascript:void(0)" id="editBtn">
				 <span class="glyphicon glyphicon-minus-sign"></span> 编辑</a>
				 <a class="btn btn-danger" href="javascript:void(0)" id="delBtn">
				 <span class="glyphicon glyphicon-remove-sign"></span> 删除</a>
			</div>
		</div>
	</div>
</div>
<div class="container">
	<div class="row">
		<div class="col-md-12">
					<div class="fixed-table-border">
						<table class="table table-condensed table-hover table-striped" style=" table-layout:fixed;overflow:hidden;">
							<tr>
								<th class="muted" width="5%">序号</th>
								<th class="muted" width="40%">话题名称</th>
								<th class="muted" width="5%">点击数</th>
								<th class="muted" width="5%">回复数</th>
								<th class="muted" width="10%">发布者</th>
								<th class="muted" width="10%">最近回复时间</th>
								<th class="muted" width="5%">操作</th>
							</tr>
							<c:forEach var="bbslist" items="${bbslist }" varStatus="status">
								<tr>
									<td>${status.index+1+pager.pageSize*(pager.pageNumber-1)}</td>
									<td><a href="commentlist?bbsid=${bbslist.id }&isclick=true">${bbslist.bbsname }</a></td>
									<td>${bbslist.clicknum }</td>
									<td>${bbslist.commentnum }</td>	
									<td>${bbslist.publisher }</td>	
									<td>${bbslist.lasttime }</td>						
									<td>
									<a class="btn btn-warning btn-sm" href="bbseditview?id=${bbslist.id}"><span class="glyphicon glyphicon-minus-sign"></span> 编辑</a>
									</td>
								</tr>
							</c:forEach>
						</table>
					</div>

		</div>
	</div>
</div>
<script type="text/javascript">
	$(function() {
		$('#selectAll').click(function() {
			if ($(this).is(':checked')) {
				$("input[name='bids']").each(function() {
					$(this).prop("checked", true);
					$(this).parent().parent().addClass('info');
				});
			} else {
				$("input[name='bids']").each(function() {
					$(this).prop("checked", false);
					$(this).parent().parent().removeClass('info');
				});
			}
		});
		$(".nav-tabs li").each(function(index) {
			if (index == 0) {
				$(this).addClass("active");
			}
		});
		$(".check-box").click(function() {
			if ($(this).is(':checked')) {
				$(this).parent().parent().addClass('info');
			} else {
				$(this).parent().parent().removeClass('info');
			}

		});
		$("#delBtn").click(function() {
			var count = 0;
			var ids = new Array();
			$("input[name='bids']").each(function() {
				if ($(this).is(':checked')) {
					count++;
					ids.push($(this).val());
				}
			});
			if(parseInt(count)==0)
				showMsg("请选择要删除的项！");
			else
			deleteConfirm(count, ids);
		});
		$('#editBtn').click(function() {
			var count = 0;
			var id;
			$("input[name='bids']").each(function() {
				if ($(this).is(':checked')) {
					count++;
					id = $(this).val();
				}
			});
			if (count == 1) {
				location.href = "courseeditview?id=" + id;
			} else if (count < 1) {
				showMsg("请选择要编辑的数据!");
				return false;
			} else {
				showMsg("只能选一条数据编辑!");
				return false;
			}
		});
	});
	function showMsg(msg) {
$("#resultModalTitle").html("<strong>" + msg + "</strong>");
		$('#resultModal').modal('show');
	}
	function deleteConfirm(count, ids) {
		$("#delModalConfirm").attr("data-delUrl", "coursedelete");
		$("#delModalConfirm").attr("data-delIDS", ids);
		$("#delModalTitle").html("你确定要删除这<strong>" + count + "</strong>条记录吗？");
		$('#delModal').modal('show');
	}
	function itemDelete() {
		$('#delModal').modal('hide');
		var url = $("#delModalConfirm").attr("data-delUrl");
		var ids = $("#delModalConfirm").attr("data-delIDS");
		/* 	if (!url || !ids) {
				alert("数据错误，未能删除");
				return;
			} */
		$.ajax({
			url : url,
			type : 'POST',
			data : {
				'ids' : ids
			},
			dataType : 'text',
			timeout : 5000,
			error : function() {
				alert('操作失败！');
			},
			success : function(result) {
				alert(result);
				window.location.reload();
			}
		});
	}
</script>

</body>
</html>